const { DataTypes } = require("sequelize");

const seq = require("../db/seq");

const Goods = seq.define(
  "zd_goods",
  {
    goods_name: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "商品名称",
    },
    goods_price: {
      type: DataTypes.DECIMAL(10, 2),
      allowNull: false,
      comment: "商品价格",
    },
    goods_num: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "商品数量",
    },
    goods_img: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "商品图片的url",
    },
  },
  {
    paranoid: true, // 创建deleteAt字段，有值 代表下架，无值 代表上架
  }
);

// 同步数据库字段
// Goods.sync({ force: true })
//   .then((res) => {
//     console.log(res);
//   })
//   .catch((error) => {
//     console.log(error);
//   });

module.exports = Goods;
